package com.zy.qudadid.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zy.lcpassenger.R;
import com.zy.qudadid.model.Bill;
import com.zy.qudadid.presenter.IndexPresenter;
import com.zy.qudadid.ui.adapter.base.BaseAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by ninos on 2016/7/22.
 */
public class IndexAdapter extends BaseAdapter<IndexAdapter.VHolder, Bill, IndexPresenter> {

    public IndexAdapter(Context context, IndexPresenter indexPresenter, View header) {
        super(context, indexPresenter, header);
        isAddFooter = false;
    }

    public IndexAdapter(Context context, IndexPresenter indexPresenter) {
        super(context, indexPresenter);
        isAddFooter = false;
    }

    @Override
    public int provideItemLayoutId() {
        return R.layout.fragment_index_item;
    }

    @Override
    public VHolder createVH(ViewGroup parent, int viewType, View view) {
        return new VHolder(view);
    }

    @Override
    public void bindData(VHolder holder, int position) {
        Bill bill = data.get(position);
        holder.ii_start.setText("起点："+bill.departure);
        holder.ii_end.setText("终点："+bill.destination);
        holder.ii_shishi.setText(bill.car_type.equals("2")?"实时":"预约");
        holder.ii_title.setText(bill.price+"元");
    }

    class VHolder extends RecyclerView.ViewHolder {

        @Nullable @Bind(R.id.ii_title)TextView ii_title;
        @Nullable @Bind(R.id.ii_shishi)TextView ii_shishi;
        @Nullable @Bind(R.id.ii_start)TextView ii_start;
        @Nullable @Bind(R.id.ii_end)TextView ii_end;
        @Nullable @Bind(R.id.ii_length)TextView ii_length;
        @Nullable @Bind(R.id.ii_qiangdan)LinearLayout ii_qiangdan;
        @Nullable @Bind(R.id.ii_img)ImageView ii_img;

        VHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
